<template>
	<view>
		<view v-for="( item , index ) in all" :key="index">
			
			<view style="display: flex;flex-direction: column;align-items: center;width: 100%;margin-top: 40rpx ;">
				<view style="display: flex;align-items: center;height: 200rpx;">
					<image :src="item.image" style="height: 200rpx;width: 175rpx;"></image>
					<view>
						<h4 style="font-weight: 700;">{{item.name}}</h4>
						<span style="font-size: 30rpx;color: darkgray">{{item.describe}}</span>
						<view style="display: flex;">
							<view style="display: flex;"><span style="font-weight: bold;">￥{{item.price}}</span><span style="font-size: 30rpx;padding-top: 10rpx;margin-left: 10rpx;">起</span></view>
							<view style="display: flex;flex-direction: column;justify-content: space-between;">
								<span @click="deleteItem(item.name)" style="text-align: center;line-height: 50rpx;margin-left: 120rpx;width: 120rpx;height: 50rpx;background-color: green;border-radius: 30rpx;color: white;font-size: 30rpx;">删除</span>
								<span @click="choose(item.name)" style="text-align: center;line-height: 50rpx;margin-left: 120rpx;width: 120rpx;height: 50rpx;background-color: green;border-radius: 30rpx;color: white;font-size: 30rpx;">修改</span>
														
							</view>
							
						</view>
					</view>
				</view>
			</view>
			
		</view>
		<view class="nav">
			<view class="item" @click="skipToKitchen()">
				<image src="../../../../static/点单.png" class="pic"></image>
				<span class="word">厨房</span>
			</view>
			<view class="item" @click="skipToTotalItems()">
				<image src="../../../../static/点单.png" class="pic"></image>
				<span class="word">仓库</span>
			</view>
			<view class="item" @click="skipToAddItem()">
				<image src="../../../../static/首页.png" class="pic" style="margin-left: 18rpx;"></image>
				<span class="word">新增</span>
			</view>
			
			
		</view>
	</view>
</template>

<script>
	import nav1 from "../../navv/nav1.js"
	export default {
		data() {
			return {
				all:[]
			}
		},
		created() {
			let t=this;
			uni.request({
				url:"http://localhost:3000/getAll",//获取商品详情
				success(arr) {
					t.all=arr.data
				}
			})
		},
		methods: {
			...nav1,
			deleteItem(name){
				uni.showModal({
					title: '提示',
					content: '确定删除吗？',
					
					success: function (res) {
						let temp={name:name}
						if(res.cancel){
							
						}
						else{
							uni.request({
								url:"http://localhost:3000/delItem",
								method:"POST",
								dataType:"json",
								data:JSON.stringify(temp),
								success(data) {
									
								}
							});
							uni.reLaunch({
								url:"/pages/index/kitchen/totalItems/totalItems"
							})
						}
						
					}
				});
				
			},
			choose(oldName){
				uni.navigateTo({
					url:`/pages/index/kitchen/updateItem/updateItem?oldName=${oldName}`
				})
			}
		}
	}
</script>

<style>
.nav{
		display: flex;
		position: fixed;
		position: fixed;
		top:92%;
		background-color: white;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
		width: 750rpx;
		height: 120rpx;
		border-top: 2rpx;
		border-style: solid;
		border-width: 2rpx;
		border-color: #d0d0d0;
		z-index: 99;
	}
	.pic{
		width: 60rpx;
		height: 80rpx;
	}
</style>
